package FileTransferIRPConstDefs;

/**
 * Generated from IDL union "FileLocation".
 *
 * @author JacORB IDL compiler V 2.3.0, 17-Feb-2007
 * @version generated at 2013-5-20 22:07:19
 */

public final class FileLocationHelper
{
	private static org.omg.CORBA.TypeCode _type;
	public static void insert (final org.omg.CORBA.Any any, final FileTransferIRPConstDefs.FileLocation s)
	{
		any.type(type());
		write( any.create_output_stream(),s);
	}

	public static FileTransferIRPConstDefs.FileLocation extract (final org.omg.CORBA.Any any)
	{
		return read(any.create_input_stream());
	}

	public static String id()
	{
		return "IDL:FileTransferIRPConstDefs/FileLocation:1.0";
	}
	public static FileLocation read (org.omg.CORBA.portable.InputStream in)
	{
		FileLocation result = new FileLocation ();
		FileTransferIRPConstDefs.LocationChoice disc = FileTransferIRPConstDefs.LocationChoice.from_int(in.read_long());
		switch (disc.value ())
		{
			case FileTransferIRPConstDefs.LocationChoice._DIRECTORY:
			{
				java.lang.String _var;
				_var=in.read_string();
				result.file_location_directory (_var);
				break;
			}
			case FileTransferIRPConstDefs.LocationChoice._URL:
			{
				java.lang.String _var;
				_var=in.read_string();
				result.file_location_url (_var);
				break;
			}
		}
		return result;
	}
	public static void write (org.omg.CORBA.portable.OutputStream out, FileLocation s)
	{
		out.write_long (s.discriminator().value ());
		switch (s.discriminator().value ())
		{
			case FileTransferIRPConstDefs.LocationChoice._DIRECTORY:
			{
				out.write_string(s.file_location_directory ());
				break;
			}
			case FileTransferIRPConstDefs.LocationChoice._URL:
			{
				out.write_string(s.file_location_url ());
				break;
			}
		}
	}
	public static org.omg.CORBA.TypeCode type ()
	{
		if (_type == null)
		{
			org.omg.CORBA.UnionMember[] members = new org.omg.CORBA.UnionMember[2];
			org.omg.CORBA.Any label_any;
			label_any = org.omg.CORBA.ORB.init().create_any ();
			FileTransferIRPConstDefs.LocationChoiceHelper.insert(label_any, FileTransferIRPConstDefs.LocationChoice.DIRECTORY);
			members[0] = new org.omg.CORBA.UnionMember ("file_location_directory", label_any, org.omg.CORBA.ORB.init().create_string_tc(0),null);
			label_any = org.omg.CORBA.ORB.init().create_any ();
			FileTransferIRPConstDefs.LocationChoiceHelper.insert(label_any, FileTransferIRPConstDefs.LocationChoice.URL);
			members[1] = new org.omg.CORBA.UnionMember ("file_location_url", label_any, org.omg.CORBA.ORB.init().create_string_tc(0),null);
			 _type = org.omg.CORBA.ORB.init().create_union_tc(id(),"FileLocation",FileTransferIRPConstDefs.LocationChoiceHelper.type(), members);
		}
		return _type;
	}
}
